package com.xujie.sportsmeeting.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 比赛项目响应VO
 */
@Data
@Schema(description = "比赛项目响应信息")
public class CompetitionEventVO {

    @Schema(description = "项目ID")
    private Long id;

    @Schema(description = "项目名称")
    private String eventName;

    @Schema(description = "项目编码")
    private String eventCode;

    @Schema(description = "项目类型")
    private Integer eventType;

    @Schema(description = "项目类型描述")
    private String eventTypeText;

    @Schema(description = "性别限制")
    private Integer genderLimit;

    @Schema(description = "性别限制描述")
    private String genderLimitText;

    @Schema(description = "最大参赛人数")
    private Integer maxParticipants;

    @Schema(description = "当前报名人数")
    private Long currentRegistrations;

    @Schema(description = "项目描述")
    private String description;

    @Schema(description = "比赛规则")
    private String rules;

    @Schema(description = "计分方式")
    private String scoringMethod;

    @Schema(description = "比赛地点")
    private String venue;

    @Schema(description = "比赛时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime competitionTime;

    @Schema(description = "比赛时长(分钟)")
    private Integer durationMinutes;

    @Schema(description = "报名开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime registrationStartTime;

    @Schema(description = "报名结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime registrationEndTime;

    @Schema(description = "状态")
    private Integer status;

    @Schema(description = "状态描述")
    private String statusText;

    @Schema(description = "是否可以报名")
    private Boolean canRegister;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    // 获取项目类型描述
    public String getEventTypeText() {
        if (eventType == null) return "";
        return eventType == 1 ? "个人项目" : "团体项目";
    }

    // 获取性别限制描述
    public String getGenderLimitText() {
        if (genderLimit == null) return "";
        switch (genderLimit) {
            case 0: return "不限";
            case 1: return "男子";
            case 2: return "女子";
            default: return "";
        }
    }

    // 获取状态描述
    public String getStatusText() {
        if (status == null) return "";
        switch (status) {
            case 0: return "禁用";
            case 1: return "正常";
            case 2: return "报名中";
            case 3: return "比赛中";
            case 4: return "已结束";
            default: return "";
        }
    }
}
